﻿using System;
using System.Web.UI.WebControls;

public class DS
{
	public static Int64 ToInt64(object value)
	{
		try { return Convert.ToInt64(value); }
		catch { return 0; }
	}

	public static int ToInt(object value)
	{
		try { return Convert.ToInt16(value); }
		catch { return 0; }
	}

	public static bool ToBoolean(object value)
	{
		try { return Convert.ToBoolean(value); }
		catch { return false; }
	}

	public static DateTime ToDateTime(object value)
	{
		try { return Convert.ToDateTime(value); }
		catch { return DateTime.MinValue; }
	}

	public static string ToShortStringDateTime(object value)
	{
		try
		{
			DateTime d = DateTime.Parse(value.ToString());
			if (d == default(DateTime))
				return String.Empty;
			return d.ToShortDateString();
		}
		catch { return String.Empty; }
	}

	public static string ToShortStringTime(object value)
	{
		try
		{
			DateTime d = DateTime.Parse(value.ToString());
			if (d == default(DateTime))
				return String.Empty;
			return d.ToShortTimeString();
		}
		catch { return String.Empty; }
	}
}
